package com.maiji.cloud.controller;


import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.IdInputDto;
import com.maiji.cloud.response.BaseOutPutDto;
import com.maiji.cloud.response.login.UserInfoResData;
import com.maiji.cloud.service.ComUserRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2019-07-04
 */
@RestController
@RequestMapping("/community")
@Api(value = "论坛模块")
public class ComUserRelationController {

    @Autowired
    ComUserRelationService comUserrelationService;


    @ApiOperation("关注人列表")
    @PostMapping("/focuserList")
    public BaseOutPutDto<List<UserInfoResData>>focuserList(@RequestBody BaseInputDto inputDto, @RequestHeader("maijiToken")String maijiToken){
        return comUserrelationService.focuserList(inputDto,maijiToken);
    }

    /**
     * 用户粉丝列表
     * @param inputDto
     * @param maijiToken
     * @return
     */
    @PostMapping("/followerList")
    @ApiOperation("用户粉丝列表")
    public BaseOutPutDto<List<UserInfoResData>>followerList(@RequestBody BaseInputDto inputDto , @RequestHeader("maijiToken")String maijiToken){
        return comUserrelationService.followerList(inputDto,maijiToken);
    }


    @PostMapping("/focusUser")
    @ApiOperation("关注用户")
    public BaseOutPutDto<String> focusUser(@RequestBody BaseInputDto<IdInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){

        return comUserrelationService.focusUser(inputDto,maijiToken);
    }

    @PostMapping("/cancelFocusUser")
    @ApiOperation("取消关注用户")
    public BaseOutPutDto<String> cancelFocusUser(@RequestBody BaseInputDto<IdInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){

        return comUserrelationService.cancelFocusUser(inputDto,maijiToken);
    }

    @PostMapping("/isFocusUser")
    @ApiOperation("是否关注用户")
    public BaseOutPutDto<Boolean> isFocusUser(@RequestBody BaseInputDto<IdInputDto> inputDto){
    	String userId = inputDto.getData().getId();
    	String maijiToken = inputDto.getData().getToken();
    	return comUserrelationService.isFocusUser(userId,maijiToken);
    }
}

